<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php');
!is_numeric($_GET['page']) ? $page = 1 : $page = (int)($_GET['page']);
$PageCount = $LinkManagePage;

if(isset($_GET['Action'])){if(!is_numeric($_GET['ID'])) MsgBox (1,'ID参数出现非数字错误！','-1');}
switch($_GET['Action']){
	case 'Del':
		$pics = new pics();
		$pics->remove_upload_files($_GET['ID'],3);		
		if($db->ExecuteSQL("DELETE FROM `" . $dbprefix . "link` WHERE `ID` = '" . $_GET['ID'] . "' LIMIT 1;")){
			AdminLog(3,$Lang,'删除友情链接(ID:' . $_GET['ID'] . ')，结果：删除成功！'); 
			MsgBox (0,'','LinkManage.php?Lang=' . $Lang . '&page=' . $page);		
		}else{
			AdminLog(3,$Lang,'删除友情链接(ID:' . $_GET['ID'] . ')，结果：删除失败！'); 
			MsgBox (1,'删除失败！','-1');	
		}
		break;
	case 'AllDel':
		$AllDel = $_POST['DelID'];
		if($AllDel == '') MsgBox (1,'操作失败，请选择要删除的友情链接！','-1');
		$AllDel = implode(',',$AllDel); //Array转成字串
		$pics = new pics();
		$pics->remove_upload_files($AllDel,3);			
		if($db->ExecuteSQL("DELETE FROM `" . $dbprefix . "link` WHERE `ID` IN (" . $AllDel . ")")){
			AdminLog(3,$Lang,'批量删除友情链接(ID:' . $AllDel . ')，结果：操作成功！'); 
			unset($AllDel);
			MsgBox (1,'操作成功！','LinkManage.php?Lang=' . $Lang . '&page=' . $page);		
		} else {
			AdminLog(3,$Lang,'批量删除友情链接，结果：操作失败！'); 
			unset($AllDel);
			MsgBox (1,'操作失败！','-1');		
		}	
		break;
	case 'y':
		if($db->ExecuteSQL("UPDATE `" . $dbprefix . "link` SET `LinkIsAudit` = '1' WHERE `ID` = '" . $_GET['ID'] . "' LIMIT 1 ;")){
			AdminLog(1,$Lang,'通过友情链接审核(ID:' . $_GET['ID'] . ')，结果：操作成功！'); 
			MsgBox (0,'','LinkManage.php?Lang=' . $Lang . '&page=' . $page);		
		}else{
			AdminLog(1,$Lang,'通过友情链接审核(ID:' . $_GET['ID'] . ')，结果：操作失败！'); 
			MsgBox (1,'操作失败！','-1');	
		}	
		break;
	case 'n':
		if($db->ExecuteSQL("UPDATE `" . $dbprefix . "link` SET `LinkIsAudit` = '0' WHERE `ID` = '" . $_GET['ID'] . "' LIMIT 1 ;")){
			AdminLog(1,$Lang,'取消友情链接审核(ID:' . $_GET['ID'] . ')，结果：操作成功！'); 
			MsgBox (0,'','LinkManage.php?Lang=' . $Lang . '&page=' . $page);		
		}else{
			AdminLog(1,$Lang,'取消友情链接审核(ID:' . $_GET['ID'] . ')，结果：操作失败！'); 
			MsgBox (1,'操作失败！','-1');	
		}	
	break;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
<script type="text/javascript"> 
function CheckAll(form) { //复选框全选/取消
	for (var i=0;i<form.elements.length;i++) { 
		var e = form.elements[i]; 
		if (e.Name != "chkAll"&&e.disabled!=true) 
		e.checked = form.chkAll.checked; 
	} 
} 
</script>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd"><td><?php TopLang();?></td>
	<td align="right">
		<input type="button" value="添加链接" onClick="javascript:location.href='LinkAdd.php?Lang=<?php echo $Lang?>'">
	</td>
	</tr>
</table>	
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <form id="form1" name="form1" method="post" action="LinkManage.php?Lang=<?php echo $Lang?>&page=<?php echo $page?>&Action=AllDel&ID=0">
  <tr>
    <td colspan="6" align="center" class="Main_Title">友情链接管理<?php echo $OnWebLangName?></td>
  </tr>
  <tr class="odd">
    <td width="50" align="center"><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox"></td>
    <td height="30" align="center"><strong>网站Logo</strong></td>
    <td align="center"><strong>链接类型</strong></td>
    <td align="center"><strong>网站名称</strong></td>
    <td align="center"><strong>排序</strong></td>
    <td align="center"><strong>操作选项</strong></td>
  </tr>
<?php
$SQL = "SELECT `ID`,`LinkType`,`LinkWebName`,`LinkWebUrl`,`LinkLogoUrl`,`LinkSort`,`LinkIsAudit` FROM `" . $dbprefix . "link` "; 
$SQL .= "WHERE `LnikLang` = '" . $Lang . "' ORDER BY `LinkSort` DESC,`ID` ASC ";
$RsCount = count($db->SelectSQL($SQL));
$SQL .= "LIMIT " . ($page-1)*$PageCount . "," . $PageCount;
foreach ($db->SelectSQL($SQL) as $i => $n){
	Html($n);
	strtolower(substr($n[4],0,7)) != 'http://' ? $LinkLogoUrl = '../' . $n[4] : $LinkLogoUrl = $n[4];
	if($n[4] == '') $LinkLogoUrl = '../images/SongCMS_88_31.gif" style="filter:gray;" title="没有上传Logo'; 
	$n[1] == 0 ? $LinkType = '文字链接' : $LinkType = 'Logo链接';
	$n[6] == 0 ? $LinkIsAudit = 'y"><font color="#FF0000">通过审核</font>' : $LinkIsAudit = 'n">取消审核';
	echo '<tr class="odd">
  	<td height="20" align="center"><input name="DelID[]" type="checkbox" id="DelID[]" value="' . $n[0] . '"></td>
  	<td align="center"><img src="' . $LinkLogoUrl . '" width="88" height="31" /></td>
  	<td align="center">' . $LinkType . '</td>
  	<td align="center"><a target="_blank" href="' . $n[3] . '">' . $n[2] . '</a></td>
  	<td align="center">' . $n[5] . '</td>
  	<td align="center"><a href="LinkUpDate.php?Lang=' . $Lang . '&page=' . $page . '&ID=' . $n[0] . '">修改</a> | 
	<a href="LinkManage.php?Lang=' . $Lang . '&page=' . $page . '&ID=' . $n[0] . '&Action=' . $LinkIsAudit . '</a> | 
	<a onClick="return confirm(\'确定要删除该友情链接吗？\');" href="LinkManage.php?Lang=' . $Lang . '&page=' . $page . '&Action=Del&ID=' . $n[0] . '">删除</a></td>
  	</tr>';
}
?>  
  <tr class="odd">
    <td width="50" align="center"><input onClick="return confirm('确定要删除所有选定的友情链接吗？');" type="submit" name="button" id="button" value="删除" /></td>
    <td height="30" colspan="5" align="center"><?php if($RsCount>0) {echo pages('Lang=' . $Lang);} else {echo '没有相关数据！';};?></td>
    </tr>
</form>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;">
注：1、Logo显示大小请在系统高级参数设定中设置；<br />
　　2、未通过审核的友情链接不在前台页面中显示；
		</td>
	</tr>
</table>  
<?php unset($SQL,$i,$n,$PageCount,$RsCount,$LinkLogoUrl);  ?>
</body>
</html>
